//
//  MenuDetailsCollectionViewCell.m
//  Cooking
//
//  Created by dllo on 15/8/25.
//  Copyright (c) 2015年 ZP.Y. All rights reserved.
//

#import "MenuDetailsCollectionViewCell.h"
#import "AppMacro.h"
#include "FoodDetailsModel.h"
#import "UIImageView+WebCache.h"

@interface MenuDetailsCollectionViewCell ()

@property (retain, nonatomic) UIImageView *topImageView;
@property (retain, nonatomic) UILabel     *foodNamelabel;

@end

@implementation MenuDetailsCollectionViewCell

- (void)dealloc {
    [_topImageView release];
    [_foodNamelabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.topImageView = [[UIImageView alloc] init];
//    _topImageView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:_topImageView];
    [_topImageView release];
    
    self.foodNamelabel = [[UILabel alloc] init];
//    _foodNamelabel.backgroundColor = [UIColor blueColor];
    _foodNamelabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_foodNamelabel];
    [_foodNamelabel release];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _topImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 30);
    _foodNamelabel.frame = CGRectMake(0, _topImageView.frame.origin.y + _topImageView.frame.size.height + 7, self.contentView.frame.size.width, 22);
}

- (void)sendValueWithModel:(FoodDetailsModel *)foodModel {
    [_topImageView sd_setImageWithURL:[NSURL URLWithString:foodModel.imagePathThumbnails] placeholderImage:[UIImage imageNamed:@"zhanwei_02.png"]];
    _foodNamelabel.text = foodModel.name;
}

@end
